<?php

declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */

namespace Plugin\Attractions\Commerce\Request\Commerce_address;

use Hyperf\Validation\Request\FormRequest;

/**
 * 快递地址信息验证数据类
 */
class CommerceAddressRequest extends FormRequest
{

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            //姓名 验证
            'name' => 'required',
            //手机号码 验证
            'phone' => 'required',
            //省 验证
            'province' => 'required',
            //市 验证
            'city' => 'required',
            //区 验证
            'district' => 'required',
            //地址 验证
            'address' => 'required',
            'is_default' => 'in:1,2'

        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => 'ID',
            'name' => trans('commerce.address.name'),
            'phone' => trans('commerce.address.phone'),
            'province' => trans('commerce.address.province'),
            'city' => trans('commerce.address.city'),
            'district' => trans('commerce.address.district'),
            'address' => trans('commerce.address.address'),
            'is_default' => trans('commerce.address.is_default'),

        ];
    }

    public function messages(): array
    {
        return [
            'id.required' => trans('commerce.address.id.required'),
            'name.required' => trans('commerce.address.name.required'),
            'phone.required' => trans('commerce.address.phone.required'),
            'province.required' => trans('commerce.address.province.required'),
            'city.required' => trans('commerce.address.city.required'),
            'district.required' => trans('commerce.address.district.required'),
            'address.required' => trans('commerce.address.address.required'),
            'is_default.*' => trans('commerce.address.is_default.param'),
        ];
    }
}
